//
//  UIBarButtonItem+Extension.swift
//  QingLiuSwift
//
//  Created by xyanl on 2024/1/3.
//  Copyright © 2024 考拉🐨. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(
        title: String, 
        titleColor: UIColor = UIColor(hex: "#333333"),
        font: UIFont = .systemFont(ofSize: 15, weight: .medium),
        frame: CGRect? = nil,
        _ target: Any?, 
        action: Selector
    ) {
        let button = UIButton(type: .custom)
        button.setTitle(title, for: .normal)
        button.setTitleColor(titleColor, for: .normal)
        button.titleLabel?.font = font
        // button.adjustsImageWhenHighlighted = false
        if frame != nil {
            button.frame = frame!
        }
        button.addTarget(target, action: action, for: .touchUpInside)
        self.init(customView: button)
    }
    
}
